package clientApp;

import java.util.ArrayList;

import javax.swing.JOptionPane;


import clientApp.utils.RPG_Workstation_Container;

import game.referenceValues.UnitClass;

import game.units.Attribute;
import game.units.Character;

/**
 *
 * @author Gabriel
 */
@SuppressWarnings("serial")
public class CharacterBuilder2 extends javax.swing.JPanel {

	RPG_Workstation_Container container;
	Character character;
	ArrayList<UnitClass> classes;
	UnitClass lvlClass;
	boolean isNewChar = false;
	boolean isLvlUp = false;
	
    /** Creates new form CharacterBuilder2 */
    public CharacterBuilder2(RPG_Workstation_Container rpg_Workstation_Container, Character character, UnitClass lvlClass, boolean isNewChar) {
    	UnitClass tempClass = new UnitClass();
    	classes = tempClass.getClasses();
    	this.container = rpg_Workstation_Container; 
    	this.character = character;
    	this.lvlClass = lvlClass;
    	this.isNewChar = isNewChar;
        initComponents();
        initValues();
        
    }

    private void initValues() {
		// TODO Auto-generated method stub
    	initClassTextFields();
    	jTFCharLevel.setText(""+character.getLevel());
	}

	private void initClassTextFields() {
		if(character.getClasses().size() > 0)
    	{
    		jTFClassName1.setText(character.getClasses().get(0).getName());
    		jTFClassLevel1.setText(""+character.getClasses().get(0).getLvl());
    		if(character.getClasses().size() > 1)
    		{
    			jTFClassName2.setText(character.getClasses().get(1).getName());
    			jTFClassLevel2.setText(""+character.getClasses().get(1).getLvl());
    			if(character.getClasses().size() > 2)
    			{
    				jTFClassName3.setText(character.getClasses().get(2).getName());
    				jTFClassLevel3.setText(""+character.getClasses().get(2).getLvl());
    			}
    		}
    	}		
	}

    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        jLClasses = new javax.swing.JList();
        jBNext = new javax.swing.JButton();
        jBBack = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTFClassName1 = new javax.swing.JTextField();
        jTFClassName1.setEditable(false);
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTFClassLevel1 = new javax.swing.JTextField();
        jTFClassLevel1.setEditable(false);
        jTFClassLevel2 = new javax.swing.JTextField();
        jTFClassLevel2.setEditable(false);
        jLabel5 = new javax.swing.JLabel();
        jTFClassName2 = new javax.swing.JTextField();
        jTFClassName2.setEditable(false);
        jLabel6 = new javax.swing.JLabel();
        jTFClassLevel3 = new javax.swing.JTextField();
        jTFClassLevel3.setEditable(false);
        jLabel7 = new javax.swing.JLabel();
        jTFClassName3 = new javax.swing.JTextField();
        jTFClassName3.setEditable(false);
        jLabel8 = new javax.swing.JLabel();
        jBViewDetails = new javax.swing.JButton();
        jBTakeClass = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        
        jTAClassDetails = new javax.swing.JTextArea();
        jTAClassDetails.setEditable(false);
        
        jTFCharLevel = new javax.swing.JTextField();
        jTFCharLevel.setEditable(false);
        jLabel9 = new javax.swing.JLabel();
        jBLvlC1 = new javax.swing.JButton();
        jBLvlC2 = new javax.swing.JButton();
        jBLvlC3 = new javax.swing.JButton();

        jPanel1.setBackground(new java.awt.Color(0, 0, 102));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 28));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Character Class");

        jLClasses.setFont(new java.awt.Font("Tahoma", 0, 12));
        
        
        jLClasses.setModel(new javax.swing.AbstractListModel() {
        	ArrayList<UnitClass> locaClasses = classes;
            public int getSize() { return locaClasses.size(); }
            public Object getElementAt(int i) { return locaClasses.get(i).getName(); }
        });
        jScrollPane1.setViewportView(jLClasses);

        jBNext.setText("Next");
        jBNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBNextActionPerformed(evt);
            }
        });

        jBBack.setText("Back");
        jBBack.setVisible(isLvlUp);
        jBBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBBackActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Your Classes:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Class Name:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Class Level:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Class Level:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Class Name:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Class Level:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Class Name:");

        jBViewDetails.setText("View Class Details");
        jBViewDetails.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBViewDetailsActionPerformed(evt);
            }
        });

        jBTakeClass.setText("Take Class");
        jBTakeClass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBTakeClassActionPerformed(evt);
            }
        });

        jTAClassDetails.setColumns(20);
        jTAClassDetails.setRows(5);
        jScrollPane2.setViewportView(jTAClassDetails);

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Character Level:");

        jBLvlC1.setText("Level Up");
        jBLvlC1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLvlC1ActionPerformed(evt);
            }
        });

        jBLvlC2.setText("Level Up");
        jBLvlC2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLvlC2ActionPerformed(evt);
            }
        });

        jBLvlC3.setText("Level Up");
        jBLvlC3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLvlC3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jBTakeClass)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jBViewDetails))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTFCharLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTFClassName3, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTFClassLevel3, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTFClassName2, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTFClassLevel2, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTFClassName1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTFClassLevel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jBLvlC3)
                            .addComponent(jBLvlC2)
                            .addComponent(jBLvlC1))))
                .addGap(370, 370, 370))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(638, Short.MAX_VALUE)
                .addComponent(jBBack, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBNext, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTFCharLevel, jTFClassLevel1, jTFClassLevel2, jTFClassLevel3});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jBViewDetails)
                            .addComponent(jBTakeClass))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel2)
                        .addGap(5, 5, 5)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jTFClassName1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(jTFClassLevel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jBLvlC1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jTFClassName2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(jTFClassLevel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jBLvlC2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(jTFClassName3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(jTFClassLevel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jBLvlC3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(jTFCharLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 449, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBNext)
                    .addComponent(jBBack))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jBNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBNextActionPerformed
    	if(character.getClasses().size() > 0)
    	{
    		container.add(new CharacterBuilder3(container, character, lvlClass, isNewChar), "CharacterBuilder3");
            container.panels.show(container, "CharacterBuilder3");
    	}
    	else
    	{
    		JOptionPane.showMessageDialog(null, "Your character needs at least 1 class");
    	}
        
    }

    private void jBBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBBackActionPerformed
    	
    	container.add(new CharacterBuilder1(container, character, isNewChar), "CharacterBuilder1");
        container.panels.show(container, "CharacterBuilder1");
    }

    private void jBViewDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBViewDetailsActionPerformed
    	if(jLClasses.getSelectedValue() != null)
    	{
    		jTAClassDetails.setText(classes.get(jLClasses.getSelectedIndex()).getDescription());
    	}
    }

    private void jBLvlC1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLvlC1ActionPerformed
       if(jTFClassName1.getText() != null && character.getLevel() > character.getTotalLevel())
       {
    	   
    	   character.getClasses().get(0).setLvl((character.getClasses().get(0).getLvl()+1));
    	   lvlClass =  character.getClasses().get(0);
    	   int points = (lvlClass.getLvlSkillsPts() + character
					.getAttributes().get(Attribute.INTELLIGENCE).getModifier() + character.bonusSkillPoints);
    	   character.setSkillPointsLefts(character.getSkillPointsLefts()+points);
    	   character.setLifePoints(character.getLifePoints()+lvlClass.hpPerLevel+character.getAttributes().get(Attribute.CONSTITUTION).getModifier());
    	   character.levelUpCharacter();
    	   jTFClassLevel1.setText(""+(character.getClasses().get(0).getLvl()));
    	   jTFClassLevel1.repaint();
       }
    }
    
    private void jBLvlC2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLvlC2ActionPerformed
    	if(jTFClassName2.getText() != null && character.getLevel() > character.getTotalLevel())
        {
    		character.getClasses().get(1).setLvl((character.getClasses().get(1).getLvl()+1));
    		lvlClass =  character.getClasses().get(1);
    		int points = (lvlClass.getLvlSkillsPts() + character
					.getAttributes().get(Attribute.INTELLIGENCE).getModifier() + character.bonusSkillPoints);
    		character.setSkillPointsLefts(character.getSkillPointsLefts()+points);
    		character.setLifePoints(character.getLifePoints()+lvlClass.hpPerLevel+character.getAttributes().get(Attribute.CONSTITUTION).getModifier());
    		character.levelUpCharacter();
    		jTFClassLevel2.setText(""+(character.getClasses().get(1).getLvl()));
    		jTFClassLevel2.repaint();
        }
    }//GEN-LAST:event_jBLvlC2ActionPerformed

    private void jBLvlC3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLvlC3ActionPerformed
    	if(jTFClassName3.getText() != null && character.getLevel() > character.getTotalLevel())
        {
    		character.getClasses().get(2).setLvl((character.getClasses().get(2).getLvl()+1));
    		lvlClass =  character.getClasses().get(2);
    		int points = (lvlClass.getLvlSkillsPts() + character
					.getAttributes().get(Attribute.INTELLIGENCE).getModifier() + character.bonusSkillPoints);
    		character.setSkillPointsLefts(character.getSkillPointsLefts()+points);    		
    		character.setLifePoints(character.getLifePoints()+lvlClass.hpPerLevel+character.getAttributes().get(Attribute.CONSTITUTION).getModifier());
    		character.levelUpCharacter();
    		jTFClassLevel3.setText(""+(character.getClasses().get(2).getLvl()));
    		jTFClassLevel3.repaint();
        }
    }//GEN-LAST:event_jBLvlC3ActionPerformed

    private void jBTakeClassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBTakeClassActionPerformed
    	if(character.getLevel() > character.getTotalLevel())
    	{
    		if(character.getClasses().size() < 3)
        	{
        		UnitClass tempClass = classes.get(jLClasses.getSelectedIndex());
        		if(!character.hasClass(tempClass.getName()))
        		{
        			lvlClass =  tempClass;
    	    		tempClass.setLvl(1);
    	    		character.addClass(tempClass);
    	    		initClassTextFields();    		
    	    		jTFClassLevel1.repaint();
    	    		jTFClassLevel2.repaint();
    	    		jTFClassLevel3.repaint();
    	    		jTFClassName1.repaint();
    	    		jTFClassName2.repaint();
    	    		jTFClassName3.repaint();
    	    		character.hasNewClass = true;
    	    		if(character.getClasses().size() > 1)
    	    		{
    	    			 character.setLifePoints(character.getLifePoints()+lvlClass.hpPerLevel+ character.getAttributes().get(Attribute.CONSTITUTION).getModifier());
    	    		}
    	    		character.levelUpCharacter();
        		}
        		else
        		{
        			JOptionPane.showMessageDialog(null, "You Already have this class");
        		}
        	}
        	else
        	{
        		JOptionPane.showMessageDialog(null,"You Already Have 3 Classes");
        	}
    	}
    	else
    	{
    		JOptionPane.showMessageDialog(null, "Level Up before taking another class.");
    	}
    	
    }//GEN-LAST:event_jBTakeClassActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBBack;
    private javax.swing.JButton jBLvlC1;
    private javax.swing.JButton jBLvlC2;
    private javax.swing.JButton jBLvlC3;
    private javax.swing.JButton jBNext;
    private javax.swing.JButton jBTakeClass;
    private javax.swing.JButton jBViewDetails;
    private javax.swing.JList jLClasses;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextArea jTAClassDetails;
    private javax.swing.JTextField jTFCharLevel;
    private javax.swing.JTextField jTFClassLevel1;
    private javax.swing.JTextField jTFClassLevel2;
    private javax.swing.JTextField jTFClassLevel3;
    private javax.swing.JTextField jTFClassName1;
    private javax.swing.JTextField jTFClassName2;
    private javax.swing.JTextField jTFClassName3;
    // End of variables declaration//GEN-END:variables
}
